<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="../../js/constant/url.js"></script>
    <link rel="stylesheet" href="css/register.css">
    <title>注册</title>
</head>

<body>
    <div id="app">
        <div class="register-container">
            <h1>注 &emsp; 册</h1>
            <div class="form-group">
                <label>用户名</label>
                <div class="input-wrapper">
                    <input type="text" v-model="username" @input="validateUsername" placeholder="请输入用户名">
                    <span class="valid-icon" v-if="usernameValid">✓</span>
                </div>
                <p class="error-message" v-if="usernameError">{{ usernameError }}</p>
            </div>
            <div class="form-group">
                <label>密码</label>
                <div class="input-wrapper">
                    <input type="password" v-model="password" @input="validatePassword" placeholder="请输入密码">
                    <span class="valid-icon" v-if="passwordValid">✓</span>
                </div>
                <p class="error-message" v-if="passwordError">{{ passwordError }}</p>
            </div>
            <div class="form-group">
                <label>确认密码</label>
                <div class="input-wrapper">
                    <input type="password" v-model="confirmPassword" @input="validateConfirmPassword" placeholder="请再次输入密码">
                    <span class="valid-icon" v-if="confirmPasswordValid">✓</span>
                </div>
                <p class="error-message" v-if="confirmPasswordError">{{ confirmPasswordError }}</p>
            </div>
            <button class="register-btn" @click="handleRegister" :disabled="!isFormValid">注册</button>
            <div class="links">
                <a href="login.html" class="login-link">已有账号？去登录</a>
            </div>
        </div>
    </div>
    <script src="js/register.js"></script>
</body>

</html>